//
//  ActivityCell.m
//  MJApp
//
//  Created by John on 15/5/5.
//  Copyright (c) 2015年 wangliang. All rights reserved.
//

#import "ActivityCell.h"
@interface ActivityCell()
@property (weak, nonatomic) IBOutlet UILabel *commentLabel;
@property (weak, nonatomic) IBOutlet UILabel *goodLabel;
@property (weak, nonatomic) IBOutlet UIImageView *image;

@end
@implementation ActivityCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

+ (instancetype)cellForTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{

    static NSString * ID = @"ActivityCell";
    
    ActivityCell * cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[NSBundle mainBundle] loadNibNamed:ID owner:nil options:nil].lastObject;
    }
    cell.cellH = 200;
    return cell;
}
- (IBAction)commitBtn:(id)sender {
    
    if ([self.delegate respondsToSelector:@selector(comment:)]) {
        
        [self.delegate comment:self.infoDic];
    }
}
- (IBAction)joinUserBtn:(id)sender {
    
    if ([self.delegate respondsToSelector:@selector(joinUser:)]) {
        [self.delegate joinUser:self.infoDic];
    }
    
}

-(void)setFrame:(CGRect)frame{

    frame.size.height -= 10;
    frame.origin.x += 10;
    frame.size.width -= 20;
    [super setFrame:frame];
    
}
- (void)setInfoDic:(NSDictionary *)infoDic{

    [super setInfoDic:infoDic];
    [self.image sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",kUrl,infoDic[@"img"]]] placeholderImage:nil];
    self.commentLabel.text = [NSString stringWithFormat:@"%@",infoDic[@"activity_discuss"]];
    self.goodLabel.text = [NSString stringWithFormat:@"%@",infoDic[@"join_users"]];
    
}
@end
